package com.dongdong.data;

/**
 * @Deacription TODO
 * @Author Lenovo
 * @Date 2020/12/9 22:35
 * @Version 1.0
 **/
public class DataResult<T> {

    private Integer code;//响应码
    private String message;//相应数据
    private T data;//数据

    public static DataResult response(ResponseStatusEnum responseStatusEnum){
        return new DataResult(responseStatusEnum.getIndex(),responseStatusEnum.getName());
    }

//    public static DataResult ok(){
//        return new DataResult(ResponseStatusEnum.SUCCESS.getIndex(),ResponseStatusEnum.SUCCESS.getName());
//    }
//
//    public static DataResult error(){
//        return new DataResult(ResponseStatusEnum.INTERNAL_SERVER_ERROR.getIndex(),ResponseStatusEnum.INTERNAL_SERVER_ERROR.getName());
//    }
//
//    public static DataResult badRequest(){
//        return new DataResult(ResponseStatusEnum.BAD_REQUEST.getIndex(),ResponseStatusEnum.BAD_REQUEST.getName());
//    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public DataResult setData(T data) {
        this.data = data;
        return this;
    }

    public DataResult() {
    }

    public DataResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public DataResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}

